package com.shouhuobao.identity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.collectplus.express.BaseActivity2;
import com.collectplus.express.R;
import com.collectplus.express.logic.AppCache;
import com.collectplus.express.model.IdCardInfoBean;

import droid.frame.utils.lang.StringReplaceUtil;

/**
 * 实名认证结果
 */
public class VerificationResultsActivity extends BaseActivity2 {

    private IdCardInfoBean cardInfoBean = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        cardInfoBean = (IdCardInfoBean) getIntent().getSerializableExtra("bean");
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void findViewById() {
        setContentView(R.layout.activity_verification_results);
        super.findViewById();
        getAppTitle().setCommonTitle("身份认证");
        View reviewing = findViewById(R.id.reviewing_layout);
        View reviewThrough = findViewById(R.id.review_through_layout);
        View auditFailed = findViewById(R.id.audit_failed_layout);
        if (cardInfoBean != null) {
            //待审核，正在审核中
            if (cardInfoBean.getStatus() >= 1 && cardInfoBean.getStatus() < 10) {
                reviewing.setVisibility(View.VISIBLE);
                reviewThrough.setVisibility(View.GONE);
                auditFailed.setVisibility(View.GONE);
            }
            //审核成功
            else if (cardInfoBean.getStatus() >= 11 && cardInfoBean.getStatus() < 20) {
                reviewing.setVisibility(View.GONE);
                reviewThrough.setVisibility(View.VISIBLE);
                auditFailed.setVisibility(View.GONE);
                ((TextView) findViewById(R.id.review_name)).setText(cardInfoBean.getName());
                if (cardInfoBean.getIdcard().length() >= 15) {
                    ((TextView) findViewById(R.id.review_code)).setText(StringReplaceUtil.idCardReplaceWithStar(cardInfoBean.getIdcard(), 6, 4, "*"));
                } else {
                    ((TextView) findViewById(R.id.review_code)).setText(cardInfoBean.getIdcard());
                }
            }
            //审核失败
            else {
                reviewing.setVisibility(View.GONE);
                reviewThrough.setVisibility(View.GONE);
                auditFailed.setVisibility(View.VISIBLE);
                ((TextView) findViewById(R.id.audit_failed_cause)).setText(cardInfoBean.getCheckRemark());
                findViewById(R.id.resubmit_bt).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        AppCache.setCardInfoBean(null);
                        startActivity(AuthenticationActivity.class);
                        finish();
                    }
                });
            }
        }
    }
}
